DXL Attribute to Show Parent Object 3 Numbers

Hi all,

I have an attribute to show the parent object number for objects, is there a way though to return the first three levels only so for object 2.5.1.2.0-1 the result would be 2.5.1 and not as it is now 2.5.1.2

Thank you,

Michael

Object po

string metricObjNumber = ""

if(obj."Text Type" "" !=  "Heading") {

po = parent(obj)

metricObjNumber = number(po)

display metricObjNumber ""

}


BowaterHouse - Wed Nov 04 12:42:24 EST 2015

Re: DXL Attribute to Show Parent Object 3 Numbers
DHAM - Thu Nov 05 08:42:05 EST 2015

//try

Object po =current
string s
s= number(po)
if(matches("[0-9]+\\.[0-9]+\\.[0-9]+\\." ,s))s=s[0: end 0-1]
else  if(matches("[0-9]+\\.[0-9]+\\.",s))s=s[0: end 0-1]
else  if(matches("[0-9]+\\." ,s))s=s[0: end 0-1]
print s

Re: DXL Attribute to Show Parent Object 3 Numbers
BowaterHouse - Fri Nov 06 06:13:29 EST 2015

Hi DHAM,

 

Thank you for your response and code! Initially it returned no values, so I compared the code to what I had before and changed the last line to 'display s' instead of 'print s' and this worked for which ever object was selected but would return the same value for all other objects. So I had a look at some other DXL code that someone has given me in the past and adapted your code to what is shown below, and it works a treat! Thank you very much DHAM, much appreciated!

string s
s= number(obj)
if(matches("[0-9]+\\.[0-9]+\\.[0-9]+\\." ,s))s=s[0: end 0-1]
else  if(matches("[0-9]+\\.[0-9]+\\.",s))s=s[0: end 0-1]
else  if(matches("[0-9]+\\." ,s))s=s[0: end 0-1]
display s

I will mark this post as the correct answer as it has the final working code but all kudos deserves to go to DHAM. Smile